<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册(2/3)</title>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/app.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="background: #0072DC;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" ><span style="font-size: 15px;color: #FFFFFF;vertical-align: 2px;">返回</span></a>
			<h1 class="mui-title text_title" id="title">注册(2/3)</h1>
		</header>
		<div class="mui-content">
			<div class="mui-text-left main-top-margin main-content-container" style="padding-left: 15px;margin-top: 40px;">
				<p>已发送短信验证码到手机号码 <span id='spantel' class="main-color" >131 2053 0990</span></p>
			</div>
			<form class="mui-input-group">
				<div class="mui-input-row main-authcode" style="margin: 35px 0 35px 0;vertical-align: center;">
					<input id='code' type="text" class="mui-input-clear mui-input" placeholder="请填写手机验证码" style="width: 60%;">
					<span id='resend' style="border-left: 1px solid #E0E0E0;float: right;padding:10px 10px;background:#FF9955;line-height: 21px;color: #FFFFFF;font-weight: 700;font-size: 14px;width: 120px;text-align: center;;">获取验证码</span>
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='go' class="mui-btn main-btn-block"><span style="color: #FFFFFF;font-size: 18px;">下一步</span></button>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			mui.plusReady(function () {
				var current = plus.webview.currentWebview();
				var tel= current.tel;
				var srcwb=current.srcwb;
				document.getElementById("spantel").innerHTML=tel.toString().replace(/(\d{3})(\d{4})/g,'$1 $2 ');
				document.getElementById("go").addEventListener('tap',function () {
					var code=document.getElementById("code").value;
					if(!code){
						plus.nativeUI.toast('请填写验证码');
						return;
					}
					
					user.checkauthcode(code,tel,'Reg',function () {
						openPage('register3.html','register3.html',{code:code,tel:tel,srcwb:srcwb});
					});
				});
				
				var sendObj = document.querySelector('#resend');
				sendObj.addEventListener('tap',function () {
					var lock = this.getAttribute('data-lock');
					if (lock == 1) {
						plus.nativeUI.toast('稍后再试！验证码已发至短信');
						return false;
					}else{
						user.getauthcode('Reg',tel,function () {
							plus.nativeUI.toast('验证码已发至短信');
							countdown(60);
						});
					}
				},false);
				
				countdown(60);
				function countdown(s) {
					s--;
					if (s <= 0) {
						sendObj.innerHTML = '获取验证码';
						sendObj.setAttribute('data-lock', 0);
					} else {
						sendObj.innerHTML = '获取验证码('+s+')';
						sendObj.setAttribute('data-lock', 1);
						setTimeout(function() {
							countdown(s)
						}, 1000)
					}
				}
				
				showPage(current);
			});
		</script>
	</body>

</html>